#include "DialogHandler.h"
#include "nlohmann/json.hpp"

void DialogHandler::OnFileDialogDismissed(const std::vector<CefString>& file_paths)
{
	nlohmann::json result;
	result["success"] = true;
	result["data"] = {};
	for (size_t i = 0; i < file_paths.size(); i++)
	{
		result["data"].push_back(file_paths[i].ToString());
	}
	CefRefPtr<CefProcessMessage> msgBack = CefProcessMessage::Create(msgName);
	CefRefPtr<CefListValue> msgArgs = msgBack->GetArgumentList();
	std::string dataStr = result.dump();
	msgArgs->SetString(0, dataStr);
	frame->SendProcessMessage(PID_RENDERER, msgBack);
}
